import { createApp } from 'vue'
import App from './App.vue'
import pinia from './pinia/index'
import router from './router'
import dayjs from 'dayjs'
import { Icon } from '@iconify/vue'

import '@arco-design/web-vue/es/modal/style/index.css'
import '@arco-design/web-vue/es/notification/style/index.css'
import '@arco-design/web-vue/es/message/style/index.css'

import './style/tailwind.scss'
import './style/common.scss'
import './style/cover.scss'
import './style/transition.scss'
import './style/font.scss'

import './utils/log'
import './mock/main'

import { registerVCopy } from '@/directives/copy'

const app = createApp(App)

app.component('Icon', Icon)

app.config.globalProperties.$log = console.log
app.config.globalProperties.$to = (url?: string) => {
  if (!url) url = window.location.href

}
app.config.globalProperties.$dayjs = dayjs

app.use(router)
app.use(pinia)

registerVCopy(app)

app.mount('#app')

declare module '@vue/runtime-core' {
  interface ComponentCustomProperties {
    $log: Function
    $to: (url?: string) => void
    $dayjs: typeof dayjs
  }
}
